<include file="header" />
<body>
<div class="wraper">
	<div class="header flex-box">
		<a href="javascript:;"></a>
		<span class="text-center">党员缴费</span>
		<a href="{BEESCRM::U('base/memberFee/payHistory',array('member_fee_id'=>$member_fee_id))}" class="iconfont icon-wodejiaoyijilu text-right"></a>
	</div>
	<div class="form-box box-border">
		<p class="form-list">
			<select id="part">
				<option value="0">请选择党支部</option>
				<volist name="partList" id="vo">
					<option value="{BEESCRM:$vo.partment_name}">{BEESCRM:$vo.partment_name}</option>
				</volist>
			</select>
			<span class="triangle"></span>
		</p>
		<p class="form-list">
			<select id="username" name="username">
				<option value="0">请选择党员姓名</option>
			</select>
			<span class="triangle"></span>
		</p>
		<div class="form-list">
			<input type="text" class="form-control" placeholder="请输入联系方式" name="tel" id="tel" value="{BEESCRM:$number}">
		</div>
		<p class="form-list">
			<select id="year" name="year">
				<option value="">年份选择</option>
				<volist name="year" id="vo">
				<option value="{BEESCRM:$vo}">{BEESCRM:$vo}</option>
				</volist>
			</select>
			<span class="triangle"></span>
		</p>
		<p class="form-list">
			<select id="month" name="month">
				<option value="">月份选择</option>
			</select>
			<span class="triangle"></span>
		</p>
	</div>
	<if condition = "$notice">
		<div class="form-box">
			<div class="form-list lineheight15">
				<p class="text-12" style="color:#ff0000;">{BEESCRM:$notice.notice}</p>
			</div>
		</div>
	</if>
	<div class="container">
		<a href="javascript:void(0);" class="btn text-center">查询</a>
	</div>
	<input type="hidden" value="{BEESCRM:$member_fee_id}" id="id" />
</div>
<script src="/assets/base/electricityfee/js/jquery-2.1.0.min.js"></script>
<script src="/assets/base/electricityfee/js/jq.utils.js"></script>
<script src="/assets/bower_components/sweetalert/lib/sweet-alert.min.js"></script>
<link rel="stylesheet" href="/assets/bower_components/sweetalert/lib/sweet-alert.css?v={BEESCRM:$time}">
<script src="/assets/base/common/ajaxgetroominfo.js"></script>
<script>
	$('#year').val({BEESCRM:$nowYear});
	$('#month').val({BEESCRM:$nowMonth});
	$('#community').val({BEESCRM:$community_id});
	$('#building').val({BEESCRM:$building_id});
	$('#floor').val({BEESCRM:$floor_id});
	$('#room').val({BEESCRM:$room_id});

	$(function(){
		//调用房间联动js
		ajaxgetroominfo(true, true, true);
	});
    $('.tab-prize').on('click','.option',function(){
        if($(this).hasClass('other')){
            $(this).siblings().removeClass('checked');
        }
        else{
            $(this).toggleClass('checked').siblings().removeClass('checked');
        }
    });
	$(document).on('click','.btn',function(){
		var member_fee_id = $('#id').val();
		var str = '';
		var partment_name = $("#part option:selected").text();
		if(partment_name == '请选择党支部'){
			$.alert('error','请选择党支部');
			return false;
		}
		if(partment_name&&partment_name != '请选择党支部'){
			str = str + '&partment_name='+partment_name;
		}
		var username = $("#username option:selected").text();
		if(username == '请选择党员姓名'){
			$.alert('error','请选择党员姓名');
			return false;
		}
		if(username&&username != '请选择党员姓名'){
			str = str + '&username='+username;
		}

		var tel = $("#tel").val();
		if(!tel){
			$.alert('error','请填写电话号码');
			return false;
		}
		if(!(/^1[34578]\d{9}$/.test(tel))){ 
	        $.alert("error","手机号码有误，请重填！");
	        return false; 
    	}
		if(tel){
			str = str + '&tel='+tel;
		}

		var year = $("#year option:selected").text();
		if (year == '年份选择') {
			$.alert('error','请选择年份');
			return false;
		};
		if(year&& year != '全部'){
			str = str + '&year='+year;
		}

		var month = $("#month option:selected").text();

		if (month == '月份选择') {
			$.alert('error','请选择月份');
			return false;
		};
		if(month&&month != '月份选择'){
			str = str + '&month='+month;
		}
		$.ajax({
			type:'post',
			dataType:'json',
			url:'/Base/MemberFee/find/member_fee_id/'+member_fee_id ,
			data:{partment_name:partment_name,username:username,tel:tel,month:month,year:year},
			success:function(data){
				if(data.status == 'F'){
					$.alert('error','暂无该党员信息');
				}
				if(data.status == 'S'){
					var url = "/index.php?g=base&m=memberFee&a=find&member_fee_id="+ member_fee_id+str;
					window.location.href=url;
				}
			}
		});
    });
    //
    //ajax二级联动获取党员姓名
    $("#part").on('change',function(){
		var partment_name = $("#part option:selected").text();
		var member_fee_id = $('#id').val();
		$("select[name='username']").empty();
		$.ajax({
			type:'post',
			dataType:'json',
			data:{partment_name:partment_name},
			url:'/base/memberFee/getMember/member_fee_id/'+member_fee_id ,
			success:function(data){
				if(data.status == 'S'){
					var str='<option value="">请选择党员姓名</option>';
					$.each(data.data,function(k,v){
					    str+='<option value="'+v.username+'">'+v.username+'</option>';
					})
					$("select[name='username']").append(str);
				}else{
					var str='<option value="">请选择党员姓名</option>';
					$("select[name='username']").append(str);
				}
			}
		})
	})
	//ajax二级联动获取年月关系
	$("#year").on('change',function(){
		var year = $("#year option:selected").text();
		var member_fee_id = $('#id').val();
		$("select[name='month']").empty();
		$.ajax({
			type:'post',
			dataType:'json',
			data:{year:year},
			url:'/base/memberFee/ytom/member_fee_id/'+member_fee_id ,
			success:function(data){
				if(data.status == 'S'){
					var str='<option value="">请选择月份</option>';
					$.each(data.data,function(k,v){
					    str+='<option value="'+v+'">'+v+'</option>';
					})
					$("select[name='month']").append(str);
				}else{
					var str='<option value="">请选择月份</option>';
					$("select[name='month']").append(str);
				}
			}
		})
	})
	//ajax获取当前党员的电话号码
	$("#username").on('change',function () {
        var member_fee_id = $('#id').val();
		var username = $("#username").val();
		var partment_name = $("#part").val();
		$.ajax({
			type:'post',
			dataType:'json',
			url:'/base/memberFee/getNum/member_fee_id/'+member_fee_id,
			data:{'username':username,'partment_name':partment_name},
			success:function (data) {
			    if(data.status =='S'){
                    $("#tel").val(data.data);
                    $("#tel").attr("readOnly",true);
				}
            }
		})
    })
</script>
</body>
</html>